function speelgoedingen

cfg.subject     = 'TJ';
cfg.ROI         = 'MT';
load(['R:\fMRI SVM\Matlab\' cfg.subject '\SVM Matrices\' cfg.ROI '_' cfg.subject ' .mat'])
%load('/home/scratch/NS-fMRIstijl/fMRI SVM/Matlab/TJ/SVM Matrices/MT_TJ .mat')

data.cmatrix    = cell(1,size(data.matrix,3));
data.relvol     = logical(data.relvol);
data.matrices   = cell(1,size(data.matrix,3));

for n=1:size(data.matrix,3);
    data.cmatrix{n} = zeros(size(data.matrix,1),size(data.matrix,2));
    data.cmatrix{n} = data.matrix(:,(data.relvol(:,n)),n);
end

for n=1:size(data.matrix,3);
    data.matrices{n} = maakmatrix(data.cmatrix{n},size(data.cmatrix{n}));
end

totaltime = 0;
for n=1:size(data.matrix,3);
  totaltime = totaltime+size(data.matrices{n},2); 
end

totalmatrix = zeros(size(data.matrices{n},1), totaltime);
l=1;
for n=1:size(data.matrix,3);
   totalmatrix(:,l:l+size(data.matrices{n},2)-1) = data.matrices{n}; 
   l = l+size(data.matrices{n},2);
end

figure
imagesc(totalmatrix)
colormap('gray')
ylabel('voxels')

end

function matr=maakkolom(mat, i, size)
    matr         = zeros(570,1);          
    l = 1;
    for n=(i-1):(i+8)
        matr(l:l+size(1)-1,1) = mat(:,n); 
        l = l+size(1);
    end
end

function matr=maakmatrix(mat, size)
  msize     = [10*size(1) size(2)-9];
  matr      = zeros(msize(1),msize(2));          % an "empty" 570x78-matrix
  for i=1:msize(2)
     matr(:,i) = maakkolom(mat, i+1, size);      %replace every collumn of matrix2
  end
end
    